#pragma once

#include "ModelessDialog.h"

class C_Execution;

// ExecutionDlg dialog

class ExecutionDlg : public CModelessDialog, public L_Observer
{
	DECLARE_DYNAMIC(ExecutionDlg)

public:
	ExecutionDlg(CWnd* pParent = NULL);   // standard constructor
	ExecutionDlg(L_Position *p, CWnd* pParent = NULL);
	ExecutionDlg(L_Order *o, CWnd* pParent = NULL);
	virtual ~ExecutionDlg();

	virtual BOOL Create(CWnd *pParentWnd = CWnd::FromHandle(L_GetMainWnd()));

// Dialog Data
	enum { IDD = IDD_EXECUTIONDLG };

protected:
	enum EXECUTIONS_SRC {
		NO_SRC,
		POSITION_EXECUTIONS,
		ORDER_EXECUTIONS
	};

	enum EXECUTION_DISP_TYPE {
		ALL_EXEC,
		BUY_EXEC,
		SELL_EXEC,
		TO_MATCH_EXEC
	};

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()

	typedef std::vector<const C_Execution> Executions;

protected:
// L_Observer
	virtual void HandleMessage(L_Message const *pMsg);

private:
	char APIFunctions[64][32];
	void SetAPIFunctions();

	//Controls
	CListCtrl m_ExecDataListCtrl;
	CComboBox m_ExecCombo;

	//Helper Functions
	void InitializeExecutions();
	void InitializeDataCtrlRows();
	void ResizeControls();
	void PopulateExecCombo();
	CString GetTextForFunction(int function);
	void UpdateValues();

	//settings
	int m_ExecutionsSrc;
	int m_DispType;

	//data
	L_Account *account;
	L_Position *position;
	L_Order *order;
	C_Execution *m_pExecution;
	Executions m_AllExecutions;
	Executions m_BuyExecutions;
	Executions m_SellExecutions;
	Executions m_ToMatchExecutions;

public:
	virtual BOOL OnInitDialog();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnBnClickedAllRadio();
	afx_msg void OnBnClickedBuyRadio();
	afx_msg void OnBnClickedSellRadio();
	afx_msg void OnBnClickedToMatchRadio();
	afx_msg void OnCbnSelchangeExecutionsCombo();
};
